home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / avifmt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  8.5 KB  |  255 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*        AVIFMT.H - Include file for working with AVI files                */
  4. /*                                                                          */
  5. /*        Note: You must include WINDOWS.H and MMSYSTEM.H before            */
  6. /*        including this file.                                              */
  7. /*                                                                          */
  8. /*        Copyright (c) 1991-1997, Microsoft Corp.  All rights reserved.    */
  9. /*                                                                          */
  10. /*                                                                          */
  11. /****************************************************************************/
  12.  
  13. #ifndef __AVIFMT_H
  14. #define __AVIFMT_H
  15. #define _INC_AVIFMT    100    /* version number * 100 + revision */
  16. #pragma option push -b
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {            /* Assume C declarations for C++ */
  20. #endif    /* __cplusplus */
  21.  
  22. // begin_vfw32
  23.  
  24. #ifdef _MSC_VER
  25. #pragma warning(disable:4200)
  26. #endif
  27.  
  28. /* The following is a short description of the AVI file format.  Please
  29.  * see the accompanying documentation for a full explanation.
  30.  *
  31.  * An AVI file is the following RIFF form:
  32.  *
  33.  *    RIFF('AVI'
  34.  *          LIST('hdrl'
  35.  *            avih(<MainAVIHeader>)
  36.  *                  LIST ('strl'
  37.  *                      strh(<Stream header>)
  38.  *                      strf(<Stream format>)
  39.  *                      ... additional header data
  40.  *            LIST('movi'
  41.  *            { LIST('rec'
  42.  *                    SubChunk...
  43.  *                 )
  44.  *                | SubChunk } ....
  45.  *            )
  46.  *            [ <AVIIndex> ]
  47.  *      )
  48.  *
  49.  *    The main file header specifies how many streams are present.  For
  50.  *    each one, there must be a stream header chunk and a stream format
  51.  *    chunk, enlosed in a 'strl' LIST chunk.  The 'strf' chunk contains
  52.  *    type-specific format information; for a video stream, this should
  53.  *    be a BITMAPINFO structure, including palette.  For an audio stream,
  54.  *    this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
  55.  *
  56.  *    The actual data is contained in subchunks within the 'movi' LIST
  57.  *    chunk.  The first two characters of each data chunk are the
  58.  *    stream number with which that data is associated.
  59.  *
  60.  *    Some defined chunk types:
  61.  *           Video Streams:
  62.  *                  ##db:    RGB DIB bits
  63.  *                  ##dc:    RLE8 compressed DIB bits
  64.  *                  ##pc:    Palette Change
  65.  *
  66.  *           Audio Streams:
  67.  *                  ##wb:    waveform audio bytes
  68.  *
  69.  * The grouping into LIST 'rec' chunks implies only that the contents of
  70.  *   the chunk should be read into memory at the same time.  This
  71.  *   grouping is used for files specifically intended to be played from
  72.  *   CD-ROM.
  73.  *
  74.  * The index chunk at the end of the file should contain one entry for
  75.  *   each data chunk in the file.
  76.  *
  77.  * Limitations for the current software:
  78.  *    Only one video stream and one audio stream are allowed.
  79.  *    The streams must start at the beginning of the file.
  80.  *
  81.  *
  82.  * To register codec types please obtain a copy of the Multimedia
  83.  * Developer Registration Kit from:
  84.  *
  85.  *  Microsoft Corporation
  86.  *  Multimedia Systems Group
  87.  *  Product Marketing
  88.  *  One Microsoft Way
  89.  *  Redmond, WA 98052-6399
  90.  *
  91.  */
  92.  
  93. #ifndef mmioFOURCC
  94. #define mmioFOURCC( ch0, ch1, ch2, ch3 )                \
  95.         ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) |    \
  96.         ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
  97. #endif
  98.  
  99. /* Macro to make a TWOCC out of two characters */
  100. #ifndef aviTWOCC
  101. #define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
  102. #endif
  103.  
  104. typedef WORD TWOCC;
  105.  
  106. /* form types, list types, and chunk types */
  107. #define formtypeAVI             mmioFOURCC('A', 'V', 'I', ' ')
  108. #define listtypeAVIHEADER       mmioFOURCC('h', 'd', 'r', 'l')
  109. #define ckidAVIMAINHDR          mmioFOURCC('a', 'v', 'i', 'h')
  110. #define listtypeSTREAMHEADER    mmioFOURCC('s', 't', 'r', 'l')
  111. #define ckidSTREAMHEADER        mmioFOURCC('s', 't', 'r', 'h')
  112. #define ckidSTREAMFORMAT        mmioFOURCC('s', 't', 'r', 'f')
  113. #define ckidSTREAMHANDLERDATA   mmioFOURCC('s', 't', 'r', 'd')
  114. #define ckidSTREAMNAME        mmioFOURCC('s', 't', 'r', 'n')
  115.  
  116. #define listtypeAVIMOVIE        mmioFOURCC('m', 'o', 'v', 'i')
  117. #define listtypeAVIRECORD       mmioFOURCC('r', 'e', 'c', ' ')
  118.  
  119. #define ckidAVINEWINDEX         mmioFOURCC('i', 'd', 'x', '1')
  120.  
  121. /*
  122. ** Stream types for the <fccType> field of the stream header.
  123. */
  124. #define streamtypeVIDEO         mmioFOURCC('v', 'i', 'd', 's')
  125. #define streamtypeAUDIO         mmioFOURCC('a', 'u', 'd', 's')
  126. #define streamtypeMIDI        mmioFOURCC('m', 'i', 'd', 's')
  127. #define streamtypeTEXT          mmioFOURCC('t', 'x', 't', 's')
  128.  
  129. /* Basic chunk types */
  130. #define cktypeDIBbits           aviTWOCC('d', 'b')
  131. #define cktypeDIBcompressed     aviTWOCC('d', 'c')
  132. #define cktypePALchange         aviTWOCC('p', 'c')
  133. #define cktypeWAVEbytes         aviTWOCC('w', 'b')
  134.  
  135. /* Chunk id to use for extra chunks for padding. */
  136. #define ckidAVIPADDING          mmioFOURCC('J', 'U', 'N', 'K')
  137.  
  138. /*
  139. ** Useful macros
  140. **
  141. ** Warning: These are nasty macro, and MS C 6.0 compiles some of them
  142. ** incorrectly if optimizations are on.  Ack.
  143. */
  144.  
  145. /* Macro to get stream number out of a FOURCC ckid */
  146. #define FromHex(n)    (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
  147. #define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
  148.                                              (FromHex(HIBYTE(LOWORD(fcc))))))
  149.  
  150. /* Macro to get TWOCC chunk type out of a FOURCC ckid */
  151. #define TWOCCFromFOURCC(fcc)    HIWORD(fcc)
  152.  
  153. /* Macro to make a ckid for a chunk out of a TWOCC and a stream number
  154. ** from 0-255.
  155. */
  156. #define ToHex(n)    ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
  157. #define MAKEAVICKID(tcc, stream) \
  158.         MAKELONG((ToHex((stream) & 0x0f) << 8) | \
  159.                 (ToHex(((stream) & 0xf0) >> 4)), tcc)
  160.  
  161. /*
  162. ** Main AVI File Header
  163. */    
  164.         
  165. /* flags for use in <dwFlags> in AVIFileHdr */
  166. #define AVIF_HASINDEX        0x00000010    // Index at end of file
  167. #define AVIF_MUSTUSEINDEX    0x00000020
  168. #define AVIF_ISINTERLEAVED    0x00000100
  169. #define AVIF_TRUSTCKTYPE    0x00000800    // Use CKType to find key frames
  170. #define AVIF_WASCAPTUREFILE    0x00010000
  171. #define AVIF_COPYRIGHTED    0x00020000
  172.  
  173. /* The AVI File Header LIST chunk should be padded to this size */
  174. #define AVI_HEADERSIZE  2048                    // size of AVI header list
  175.  
  176. typedef struct
  177. {
  178.     DWORD        dwMicroSecPerFrame;    // frame display rate (or 0L)
  179.     DWORD        dwMaxBytesPerSec;    // max. transfer rate
  180.     DWORD        dwPaddingGranularity;    // pad to multiples of this
  181.                                                 // size; normally 2K.
  182.     DWORD        dwFlags;        // the ever-present flags
  183.     DWORD        dwTotalFrames;        // # frames in file
  184.     DWORD        dwInitialFrames;
  185.     DWORD        dwStreams;
  186.     DWORD        dwSuggestedBufferSize;
  187.  
  188.     DWORD        dwWidth;
  189.     DWORD        dwHeight;
  190.  
  191.     DWORD        dwReserved[4];
  192. } MainAVIHeader;
  193.  
  194. /*
  195. ** Stream header
  196. */
  197.  
  198. #define AVISF_DISABLED            0x00000001
  199.  
  200. #define AVISF_VIDEO_PALCHANGES        0x00010000
  201.  
  202. typedef struct {
  203.     FOURCC        fccType;
  204.     FOURCC        fccHandler;
  205.     DWORD        dwFlags;    /* Contains AVITF_* flags */
  206.     WORD        wPriority;
  207.     WORD        wLanguage;
  208.     DWORD        dwInitialFrames;
  209.     DWORD        dwScale;    
  210.     DWORD        dwRate;    /* dwRate / dwScale == samples/second */
  211.     DWORD        dwStart;
  212.     DWORD        dwLength; /* In units above... */
  213.     DWORD        dwSuggestedBufferSize;
  214.     DWORD        dwQuality;
  215.     DWORD        dwSampleSize;
  216.     RECT        rcFrame;
  217. } AVIStreamHeader;
  218.  
  219. /* Flags for index */
  220. #define AVIIF_LIST          0x00000001L // chunk is a 'LIST'
  221. #define AVIIF_KEYFRAME      0x00000010L // this frame is a key frame.
  222.  
  223. #define AVIIF_NOTIME        0x00000100L // this frame doesn't take any time
  224. #define AVIIF_COMPUSE       0x0FFF0000L // these bits are for compressor use
  225.  
  226. typedef struct
  227. {
  228.     DWORD        ckid;
  229.     DWORD        dwFlags;
  230.     DWORD        dwChunkOffset;        // Position of chunk
  231.     DWORD        dwChunkLength;        // Length of chunk
  232. } AVIINDEXENTRY;
  233.  
  234. /*
  235. ** Palette change chunk
  236. **
  237. ** Used in video streams.
  238. */
  239. typedef struct
  240. {
  241.     BYTE        bFirstEntry;    /* first entry to change */
  242.     BYTE        bNumEntries;    /* # entries to change (0 if 256) */
  243.     WORD        wFlags;        /* Mostly to preserve alignment... */
  244.     PALETTEENTRY    peNew[];    /* New color specifications */
  245. } AVIPALCHANGE;
  246.  
  247. // end_vfw32
  248.  
  249. #ifdef __cplusplus
  250. }                       /* End of extern "C" { */
  251. #endif    /* __cplusplus */
  252.  
  253. #pragma option pop
  254. #endif /* _INC_AVIFMT */
  255.